
//bean
function CollectObsBean() {
  let tag;
  let activityId;
  let callBack;
  //callBack simple
  // function CallBack( result) {
  // }
};

//CollectObsBean. tag
let Tag = {
  'find': 'find',
  'index': 'index',
  'interest': 'interest',
  'near': 'near',
  'search': 'search'
};

let obsList = []; // collectObsBean list

function addActivity(collectObsBean) {
  if (collectObsBean == null)
    return;
  obsList.push(collectObsBean);
}

function collectActivity(activityId, result) {
  if (result == null || activityId == null)
    return;
  for (let i = 0; i < obsList.length; i++) {
    let collectObsBean = obsList[i];
    if (collectObsBean.activityId === activityId) {
      collectObsBean.callBack(result);
    }
  }
}


//TODO 隐藏的界面  待删除
function deleteActivity(tag) {
  if (tag == null )
    return;

  let delList = [];

  //遍历要删除的bean
  for (let i = 0; i < obsList.length; i++) {
    let collectObsBean = obsList[i];
    if (collectObsBean.tag === tag) {
      delList.push(i);
    }
  }

  //删除bean
  for (let i = 0; i < delList.length; i++) {
    let index = delList[i] - i;
    obsList.splice(index, 1);
  }

}




module.exports = {
  collectActivity: collectActivity,
  addActivity: addActivity,
  deleteActivity: deleteActivity,
  CollectObsBean: CollectObsBean,
  Tag: Tag
};